Skip to content

Conversation

@dkropachev
Copy link

@dkropachev dkropachev commented Mar 9, 2025

Fixes: #460

CQL4 has a flaw where, after a schema change, an affected prepared statement may not be invalidated on the client side. As a result, the driver may read data that does not match the cached metadata, leading to deserialization failures or incorrect deserialization.

For more details, see: scylladb/scylladb#20860.

This commit introduces the skipCQL4MetadataResolveMethod, which determines how the driver resolves the skip metadata flag for CQL4 prepared statements. It supports three modes:
SMART (default) – Disables the skip metadata flag only for wildcard selects and selects that return UDTs (including collections and maps).
ENABLED – Always enables the skip metadata flag, metadata is being sent with every query.
DISABLED – Always disables the skip metadata flag, metadata is not being sent.

@dkropachev dkropachev self-assigned this Mar 9, 2025
@roydahan roydahan requested a review from Copilot March 9, 2025 18:10
@roydahan
Copy link
Collaborator

roydahan commented Mar 9, 2025

Do we have tests to prove it works correctly?

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Overview

This PR introduces a new mechanism, skipCQL4MetadataResolveMethod, to address a flaw in CQL4 prepared statement metadata handling. Key changes include:

  • Adding a new method, calculateSkipMetadata(), in DefaultPreparedStatement to decide whether to skip metadata resolution.
  • Integrating a configurable CQL4SkipMetadataResolveMethod within QueryOptions with new setters and getters.
  • Adjusting SessionManager to use the new skip metadata logic based on whether the statement is a DefaultPreparedStatement.

Reviewed Changes

File Description
driver-core/src/main/java/com/datastax/driver/core/DefaultPreparedStatement.java Adds skip metadata logic and logging to warn about wildcard selects and UDT usage
driver-core/src/main/java/com/datastax/driver/core/QueryOptions.java Introduces new configuration methods and enum for CQL4 skip metadata resolution
driver-core/src/main/java/com/datastax/driver/core/SessionManager.java Updates logic to determine skip metadata based on statement type

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (1)

driver-core/src/main/java/com/datastax/driver/core/DefaultPreparedStatement.java:201

  • The variable 'query' is undefined in this method. Consider passing the query string as an argument or referencing a valid class field to resolve this issue.
List<String> chunks = Splitter.onPattern("\s+").splitToList(query);

@dkropachev
Copy link
Author

Do we have tests to prove it works correctly?

Not yet

@dkropachev dkropachev force-pushed the dk/3.x-skip-metadata-flag-fix branch from 3c03a6b to a3e97e6 Compare March 9, 2025 22:11
@dkropachev
Copy link
Author

Do we have tests to prove it works correctly?

Not yet

Added

@dkropachev dkropachev requested a review from Bouncheck March 9, 2025 22:16
@dkropachev dkropachev force-pushed the dk/3.x-skip-metadata-flag-fix branch 3 times, most recently from 1efbba1 to 30ea2e9 Compare March 10, 2025 20:06
Introduce skipCQL4MetadataResolveMethod to Mitigate CQL4 Issues
CQL4 has a flaw where, after a schema change, an affected prepared statement may not be invalidated on the client side.
As a result, the driver may read data that does not match the cached metadata, leading to deserialization failures or incorrect deserialization.

For more details, see: scylladb/scylladb#20860.

This commit introduces the skipCQL4MetadataResolveMethod, which determines how the driver resolves the skip metadata flag for CQL4 prepared statements.
It supports three modes:
`SMART` (default) – Disables the skip metadata flag only for wildcard selects and selects that return UDTs (including collections and maps).
`ENABLED` – Always enables the skip metadata flag, no metadata is being
sent.
`DISABLED` – Always disables the skip metadata flag, metadata is being
sent with every bound statement RESULT frame.
@dkropachev dkropachev force-pushed the dk/3.x-skip-metadata-flag-fix branch from 30ea2e9 to 1276914 Compare March 10, 2025 20:30
@dkropachev dkropachev merged commit cd0b08e into scylladb:scylla-3.x Mar 11, 2025
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants